package com.fz.controller.merchant;

import com.fz.beans.IdBeans;
import com.fz.beans.PageBeans;
import com.fz.common.ResponseEntity;
import com.fz.dto.merchant.merUser.MerUserAdd;
import com.fz.dto.merchant.merUser.MerUserQuery;
import com.fz.dto.merchant.merUser.MerUserUpd;
import com.fz.service.merchant.MerUserService;
import com.fz.vo.merchant.merUser.MerUserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiSort;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author : xumj
 * @date : 2021/3/19 15:09
 */
@RestController
@Api(value = "用户管理", tags = "用户管理")
@RequestMapping("/merUser")
@CrossOrigin
@ApiSort(value = 2)
@SuppressWarnings("unchecked")
public class MerUserController {

    @Resource
    private MerUserService merUserService;

    @GetMapping("/findMerUserList")
    @ApiOperation(value = "查询用户分页列表")
    @ApiOperationSupport(order = 1)
    public ResponseEntity<MerUserVo> findMerUserList(MerUserQuery merUserQuery, PageBeans pageBeans) throws Exception {
        return merUserService.findMerUserList(pageBeans.getPageNum(), pageBeans.getPageSize(), merUserQuery);
    }

    @GetMapping("/selectMerUsersList")
    @ApiOperation(value = "查询用户列表")
    @ApiOperationSupport(order = 2)
    public ResponseEntity<MerUserVo> selectMerUsersList(MerUserQuery merUserQuery) throws Exception {
        return merUserService.selectMerUsersList(merUserQuery);
    }

    @PostMapping("/saveMerUser")
    @ApiOperation(value = "新增用户")
    @ApiOperationSupport(order = 3)
    public ResponseEntity saveMerUser(@RequestBody MerUserAdd merUserAdd) throws Exception {
        return merUserService.saveMerUser(merUserAdd);
    }

    @PostMapping("/updateMerUser")
    @ApiOperation(value = "修改用户")
    @ApiOperationSupport(order = 4)
    public ResponseEntity updateMerUser(@RequestBody MerUserUpd merUserUpd) throws Exception {
        return merUserService.updateMerUser(merUserUpd);
    }

    @PostMapping("/delMerUser")
    @ApiOperation(value = "删除用户")
    @ApiOperationSupport(order = 5)
    public ResponseEntity delMerUser(@RequestBody IdBeans idBeans) throws Exception {
        return merUserService.delMerUser(idBeans.getIds());
    }
}
